package work.stackandqueque;

import java.util.Stack;

public class Problem232 {

    class MyQueue {
        private Stack<Integer> A;
        private Stack<Integer> B;

        public MyQueue() {
            A = new Stack<>();
            B = new Stack<>();
        }

        public void push(int x) {
            A.push(x);
        }

        public int pop() {
            Integer peek = peek();
            B.pop();
            return peek;


        }

        public int peek() {
            if (!B.empty()) return B.peek();
            while (!A.empty()) {
                B.push(A.pop());

            }
            return B.peek();
        }

        public boolean empty() {
            if (A.empty() && B.empty()) return true;
            return false;
        }
    }



    public static void main(String[] args) {
        Problem232 problem232 = new Problem232();
        MyQueue myQueue = problem232.new MyQueue();
        myQueue.push(1);
        myQueue.pop();
    }
}